package org.jeecg.activiti.ActivitClass;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.jeecg.modules.productrecord.entity.ProductRecord;
import org.jeecg.modules.productrecord.mapper.ProductRecordMapper;

import java.util.Date;

public class PurchaseProduct implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) {
        ProductRecordMapper productRecordMapper=SpringContextHolder.getBean(ProductRecordMapper.class);
        ProductRecord productRecord=new ProductRecord();
        productRecord.setClientId((String) execution.getVariable("client_id"));
        productRecord.setProductId((String)execution.getVariable("product_id"));
        productRecord.setBuyMoney(Double.parseDouble(execution.getVariable("advance").toString()));
        productRecord.setBuyTime(new Date());
        productRecordMapper.insert(productRecord);

    }
}
